package my.io.hadoop.jobs;

import cn.hutool.db.Entity;
import cn.hutool.json.JSONUtil;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class MapToReduce extends Entity implements Writable {
    @Override
    public void write(DataOutput out) throws IOException {
        String jsonStr = JSONUtil.toJsonStr(this);
        out.writeUTF(jsonStr);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        String jsonStr = in.readUTF();
        Entity entity = JSONUtil.toBean(jsonStr, Entity.class);
        this.putAll(entity);
    }
}
